package com.lixianbiao.validation;

import com.lixianbiao.validation.annotation.Max;
import com.lixianbiao.validation.annotation.Min;
import com.lixianbiao.validation.annotation.NotNull;
import com.lixianbiao.validation.annotation.StringPattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author lixianbiao
 * @since 2024/06/21 21:55
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User {
    @NotNull(value = true, code = 101, message = "账号不能为空")
    @StringPattern(value = "^[a-zA-Z0-9._-]{6,20}$",code = 102, message = "账号格式错误")
    private String username;

    @NotNull(value = true, code = 102, message = "密码不能为空")
    @StringPattern(value = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()]).{8,}$", code = 103, message = "密码格式错误")
    private String password;

    @NotNull(value = true, code = 104, message = "电话不能为空")
    @StringPattern(value = "^(?:\\+86|86)?1[3-9]\\d{9}$|^(?:\\+86|86)?[2-9]\\d{6,7}$|^0\\d{2,3}-?\\d{7,8}$", code = 105, message = "电话格式错误")
    private String phone;

    @NotNull(value = true, code = 105, message = "年龄不能为空")
    @Max(value = 150, code = 106, message = "年龄不能超过150")
    @Min(value = 0, code = 107, message = "年龄必须大于0")
    private Integer age;
}